package com.sale.system.controller;

import com.sale.common.core.domain.R;
import com.sale.common.core.web.controller.BaseController;
import com.sale.system.domain.dto.SysTemplateDispositionDto;
import com.sale.system.domain.vo.AddDispositionVo;
import com.sale.system.service.SysTemplateDispositionService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 打印配置数据表控制层
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/template-disposition")
public class SysTemplateDispositionController extends BaseController {

    private final SysTemplateDispositionService sysTemplateDispositionService;

    /**
     * 新增配置
     */
    @PostMapping("/add")
    public R<Void> addDisposition(@RequestBody AddDispositionVo addDispositionVo) {
        return toAjax(sysTemplateDispositionService.addDisposition(addDispositionVo));
    }

    /**
     * 根据菜单id获取配置信息
     */
    @GetMapping("/getDataByMenuId/{menuId}")
    public R<List<SysTemplateDispositionDto>> getDataByMenuId(@PathVariable("menuId") Long menuId) {
        return R.ok(sysTemplateDispositionService.getDataByMenuId(menuId));
    }
}
